<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@include file="common/jspcommon.jsp" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="keywords" content="" />
<meta name="description" content="" />
<%@include file="common/jscss.jsp" %>
<title>COOLSK运营中心</title>

<script type="text/javascript">
/*
	var browserType;
	//如果浏览器为IE
	if (window.navigator.userAgent.indexOf("MSIE")>=1) {
		browserType = "IE";
		document.attachEvent("onkeypress",keyPress);
	}
	//如果浏览器为Firefox
	else if (window.navigator.userAgent.indexOf("Firefox")>=1) {
		browserType = "FIREFOX";
		document.addEventListener("keypress",fireFoxHandler, true);
	} else {
		browserType = "OTHER";
	}

	function loginSubmit(){
	
		var missingUserName = false;
		var missingPassword = false;
		var errorInfoMessage = '';

		document.getElementById('errorInfo').innerHTML = '';
		document.getElementById('errorInfo').innerHTML = '';

		if (document.getElementById('j_username').value == '') {
			missingUserName = true;
		}

		if (document.getElementById('j_password').value == '') {
			missingPassword = true;
		}

		if (!missingUserName && !missingPassword) {
			var form = document.getElementById("loginForm");			
			return form.submit();			
		}

		if (missingUserName && missingPassword) {
			errorInfoMessage = '<font color="red">请输入登录名和密码！</font>';
			document.getElementById('j_username').focus();
		} else if (missingUserName && !missingPassword) {
			errorInfoMessage = '<font color="red">请输入登录名！</font>';
			document.getElementById('j_username').focus();
		} else if (!missingUserName && missingPassword) {
			errorInfoMessage = '<font color="red">请输入密码！</font>';
			document.getElementById('j_password').focus();
		}
		document.getElementById('errorInfo').innerHTML = errorInfoMessage;
		//alert("browserType = " + browserType);
		if (browserType == "IE") {
			return;
		} else if (browserType == "FIREFOX") {
			var firedEvent = event || window.event;
			firedEvent.preventDefault();
			firedEvent.stopPropagation();
			return false;
		} else {
			return;
		}
	}
	
	function keyPress(firedEvent) {
		
		//var firedEvent = event || window.event;
		//var firedEvent = event ? event :(window.event ? window.event : null); 
		var firedSrcElement = firedEvent.target || firedEvent.srcElement;
		var firedKey = firedEvent.keyCode || firedEvent.which;
		
		//alert("firedSrcElement = " + firedSrcElement.id + "; firedKey = " +  firedKey);
		
		if (firedKey == 13
				&& firedSrcElement.id == "j_password") {
			//alert("password 13");
			return loginSubmit();
		} else if (firedKey == 13
				&& firedSrcElement.id == "j_username") {
			//alert("username 13");
			if (document.getElementById('j_password').value == '') {
				document.getElementById('j_password').focus();
			} else {
				return loginSubmit();
			}
			
		} else {
			//alert("firedKey = " + firedKey);
			//alert("firedSrcElement.id = " + firedSrcElement.id);
		}
		return;
	}
	*/
	
	$(function(){
		$("#loginForm").validate({
			rules : {
				j_username : {
					required : true
				},
				j_password : {
					required : true
				}
			},
			messages : {
				j_username : {
					required : "请输入登录名"
				},
				j_password : {
					required : "请输入密码"
				}
			},
			submitHandler : function(form) {
				form.submit();
			}
		});
		
		
	});
	function loginSubmit(){
		$("#loginForm").submit();
	}
</script>
</head>

<body>
<form name="loginForm" id="loginForm" action='<c:url value="/misc/j_spring_security_check"/>' method="post" onsubmit="return false;">
<table width="100%"  height="100%" border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td><table width="100%" border="0" cellspacing="0" cellpadding="0">
      <tr>
        <td height="561" style="background:url(/images/lbg.gif)"><table width="940" border="0" align="center" cellpadding="0" cellspacing="0">
          <tr>
            <td height="238" style="background:url(/images/login01.jpg)">&nbsp;</td>
          </tr>
          <tr>
            <td height="190"><table width="100%" border="0" cellspacing="0" cellpadding="0">
              <tr>
                <td width="208" height="190" style="background:url(/images/login02.jpg)">&nbsp;</td>
                <td width="518" style="background:url(/images/login03.jpg)"><table width="400" border="0" align="center" cellpadding="0" cellspacing="0">
                  <tr>
                    <td width="40" height="50"><img src="/images/user.gif" width="30" height="30" /></td>
                    <td width="38" height="50">用户</td>
                    <td width="300" height="50"><input type="text" id="j_username" name="j_username" style="width:164px; height:32px; line-height:34px; background:url(/images/inputbg.gif) repeat-x; border:solid 1px #d1d1d1; font-size:9pt; font-family:Verdana, Geneva, sans-serif;" /></td>
                  </tr>
                  <tr>
                    <td height="50"><img src="/images/password.gif" width="28" height="32" /></td>
                    <td height="50">密码</td>
                    <td height="50"><input type="password" id="j_password" name="j_password" style="width:164px; height:32px; line-height:34px; background:url(/images/inputbg.gif) repeat-x; border:solid 1px #d1d1d1; font-size:9pt; " /><c:if test="${param.error}"><label style="margin-left: 5px;"><font color="red">登录失败！</font></label></c:if><c:if test="${param.timeout}"><label style="margin-left: 5px;"><font color="red">会话过期，请重新登录！</font></label></c:if><c:if test="${param.logout}"><label style="margin-left: 5px;"><font color="red">你已退出！</font></label></c:if></td>
                  </tr>
                  <tr>
                    <td height="40">&nbsp;</td>
                    <td height="40">&nbsp;</td>
                    <td height="60"><img style="cursor: pointer;" onclick="loginSubmit();"  src="/images/login.gif" width="95" height="34" /></td>
                  </tr>
                </table></td>
                <td width="214" style="background:url(/images/login04.jpg)" >&nbsp;</td>
              </tr>
            </table></td>
          </tr>
          <tr>
            <td height="133" style="background:url(/images/login05.jpg)">&nbsp;</td>
          </tr>
        </table></td>
      </tr>
    </table></td>
  </tr>
</table>
</form>
</body>


<%--<body>
	<div style="width: 350px; height: 50px; margin: auto; border: 1px solid;">
		<form name="loginForm" id="loginForm" action='<c:url value="/misc/j_spring_security_check"/>' method="post" onsubmit="return false;">
			<table align="center" cellpadding="0" cellspacing="0">
				<tbody>
					<tr>
						<td align="right">用户名：</td>
						<td><input id="j_username" name="j_username" type="text" />
						</td>
						<td>&nbsp;</td>
					</tr>
					<tr>
						<th align="right" >密&nbsp;&nbsp;&nbsp;码：</th>
						<td><input id="j_password" name="j_password" type="password" />
						</td>
						<td style="padding-left: 15px"><a
							href="javascript:loginSubmit();">登录</a>
						</td>
					</tr>
					<tr>
						<th>&nbsp;</th>
						<td>
							<span id="errorInfo">
								<c:if test="${param.timeout}"><font color="red">会话过期，请重新登录！</font></c:if>
								<c:if test="${param.error}"><font color="red">登录失败！</font></c:if>
								<c:if test="${param.logout}"><font color="green">您已退出！</font></c:if>
							</span>
						</td>
						<td style="padding-left: 15px">&nbsp;</td>
					</tr>
				</tbody>
			</table>
			<input type="submit" name="submitButton" style="display: none" />
		</form>
	</div>
</body>
--%></html>
